﻿public class BuffBesieged : BuffBase
{
    public int TotalAtkFix = 0;
    public BuffBesieged() : base()
    {
        Type = BuffType.Besieged;
        TotalAtkFix = 0;
    }

    public static bool CheckCondition(UnitBase unit)
    {
        int surroundedEnermies = 0;
        foreach (Cell neighbour in unit.cell.Neighbours)
        {
            if (neighbour.Unit != null && neighbour.Unit.team != unit.team)
            {
                surroundedEnermies += 1;
            }
        }
        return surroundedEnermies == unit.cell.Neighbours.Count;
    }

    public override void Update()
    {
        if (!BuffBesieged.CheckCondition(Owner))
        {
            Owner.RemoveBuff(this);
        }
    }

    public override void OnCreate()
    {
        //Owner.atk_fix -= 1;
        //TotalAtkFix += 1;
    }

    public override void OnEndPhase()
    {
        Owner.atk_fix -= 1;
        TotalAtkFix += 1;
    }

    public override void OnDispose()
    {
        Owner.atk_fix += TotalAtkFix;
        TotalAtkFix = 0;
    }
    public override string ToString()
    {
        return "被围攻：每回合损失攻击力";
    }
}